package org.computate.model.item;

import com.googlecode.objectify.annotation.Cached;
import com.googlecode.objectify.annotation.Subclass;

@Cached
@Subclass
public class Page extends Model {
	
	public String getModelDisplayName() { return "Page"; }
	public String getModelPluralName() { return "Pages"; }
	String pageName;

	public Page() {
		super();
		setPhotosPermitted(true);
	}
	
	@Override
	public void addFields() {
		super.addFields();
		
		removeField("name");
		addField("name", "Name:").setInIndex(true).setHeader(2);
		addField("description", "HTML Content:").setTextarea(true).setWysiwyg(true);
	}
	
	/*
	@Override
	public void set(String field, String value, ModelService modelService, PersistenceManager pm, HttpServletRequest request) {
		super.set(field, value, modelService, pm, request);
	}
	*/
	
	public String getPageName() {
		return pageName;
	}

	public void setPageName(String pageName) {
		this.pageName = pageName.replace(' ', '_').toLowerCase();
	}
	
	@Override
	public void setName(String name) {
		super.setName(name);
		setPageName(name);
	}
	
	/*
	@Override
	public void removeCache(Cache cache) {
		super.removeCache(cache);
		
		String cacheString1 = new StringBuilder("Page").append(" first field ").append("pageName").append(" value ").append(getPageName()).toString();
		
		cache.remove(cacheString1);
	}
	*/
}
